package LC;

/**
 * @ClassName LC53
 * @Description: TODO
 * @Author hl
 * @Date 2020/9/13
 * @Version V1.0
 **/
public class LC53 {
    public int maxSubArray(int[] nums) {
        int temp=0;
        int res=Integer.MIN_VALUE;
        for(int i=0;i<nums.length;i++){
          if(temp<=0){
              temp=nums[i];
          }else{
              temp+=nums[i];
          }

          if(temp>res){
              res=temp;
          }
        }
        return res;
    }
}
